﻿using System;
using System.Threading.Tasks;
using Iot.Shared.EventBusSend;
using Iot.TimingDatabase.Models;

namespace Iot.TimingDatabase.Helper;

public static class EventBusSendHelp
{
    /// <summary>
    ///     设备类型 DeviceModule据发送    此接口 发送出去的数据都会记录到时序数据库内
    /// </summary>
    /// <param name="send"></param>
    /// <param name="data"></param>
    /// <param name="timeStamp"></param>
    /// <returns></returns>
    public static async Task SendDeviceModuleAsync<T>(this IEventBusSend send, T data,
        DateTimeOffset? timeStamp = null)
        where T : DeviceModule
    {
        ArgumentNullException.ThrowIfNull(data);
        await send.SendAsync(data, timeStamp);
    }
}